//
//  ViewController.m
//  STNewTools
//
//  Created by stoneobs on 17/1/11.
//  Copyright © 2017年 stoneobs. All rights reserved.
//

#import "ViewController.h"
#import "UIViewController+STNavigationTools.h"
#import "UIViewController+STPresent.h"
#import "STPickerViewController.h"
#import "STPopViewController.h"
#import "STWebViewController.h"
#import "STAdvertingScrollView.h"
#import "STRadioButton.h"
#import "STSegementButton.h"
#import "STImagePickerController.h"
#import "TZImagePickerController.h"
#import "AFNetworking.h"
#import <AVFoundation/AVFoundation.h>
#import "UIViewController+STNavigationTools.h"
#import "UIImage+STTools.h"
#import "STVideoPlayView.h"
#import "STBlockTestViewController.h"
#import "STKvoTestViewController.h"
#import "STStructViewController.h"
#import "STRuntimeStudyViewController.h"
#import "STJsonViewController.h"
#import "Chameleon.h"
#import "UINavigationController+WXSTransition.h"
#import "UIViewController+WXSTransition.h"
#import "STButton.h"
#import "UIView+STShadow.h"
#import "STAVResourseNetTask.h"
#import "STPlayViewLoaderController.h"
#import "STRichViewController.h"
#import "UIImage+STTools.h"
#import "STCalendarKitView.h"
#import "STCollectionViewController.h"
#define SCREEN_HEIGHT  [UIScreen mainScreen].bounds.size.height
#define SCREEN_FRAME  [UIScreen mainScreen].bounds
#define SCREEN_WIDTH  [UIScreen mainScreen].bounds.size.width
@interface ViewController ()
@property(nonatomic,strong)STAdvertingScrollView            *adverView;
//@property(nonatomic,strong)AVPlayer                         *player;
@property(nonatomic,strong)NSMutableArray                   *testArray;

@property(nonatomic,strong)UIImageView            *testImageView;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor grayColor];

    [self setRightItemWithTitle:@"test"];


    
    STCalendarKitView * text = [[STCalendarKitView alloc] initWithFrame:CGRectMake(0, 100, SCREEN_WIDTH, itemWith * 7) delegate:self];
    
    [self.view addSubview:text];


   // [self hgTest];
}
-(void)viewWillAppear:(BOOL)animated
{
    
  //  [self.navigationController.navigationBar setBackgroundImage:[UIImage imageWithColor:[UIColor redColor] size:CGSizeMake(SCREEN_WIDTH, 64)] forBarMetrics:UIBarMetricsDefault];
 //   [self.navigationController.navigationBar setShadowImage:[UIImage imageWithColor:[UIColor blueColor] size:CGSizeMake(SCREEN_WIDTH, 1)]];
    [super viewWillAppear:animated];
    
}
- (void)viewWillDisappear:(BOOL)animated
{
    
    [super viewWillDisappear:animated];
}
- (BOOL)shouldAutorotate
{
    return NO;
}
- (UIStatusBarStyle)preferredStatusBarStyle {
    // 这里设置横竖屏不同颜色的statusbar
    // if (ZFPlayerShared.isLandscape) {
    //    return UIStatusBarStyleDefault;
    // }
    return UIStatusBarStyleLightContent;
}
#pragma mark ---tableview datasouse and delegate start
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 0;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 44;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 24;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0.1;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell * cell =[tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (!cell) {
        cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
    }
    cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [self rightBarAction:nil];
    
    
}
#pragma mark ---tableview datasouse and delegate end
- (void)rightBarAction:(id)sender
{

//    [self hgTest];
    
    [self.navigationController pushViewController:[STCollectionViewController new] animated:YES];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
#pragma mark --视屏缓存测试
- (void)avLoaderTest{

    [self.navigationController pushViewController:[STPlayViewLoaderController new] animated:YES];
}
- (void)jsonTest{
    STJsonViewController    *vc = [STJsonViewController new];
    __weak typeof(self) weakSelf =self;
    [self.navigationController wxs_pushViewController:vc makeTransition:^(WXSTransitionProperty *transition) {
        transition.animationType = WXSTransitionAnimationTypeViewMoveToNextVC;
        transition.startView = weakSelf.testImageView;
        transition.targetView = vc.testImageView;
        
    }];
}
#pragma mark --picker
- (void)areaPickerTest{

    STPickerViewController * picker = [[STPickerViewController alloc] initWithDefualtAreaPickerWithHandle:^(NSString *finshString, NSString *city, NSString *provence) {
        
    }];
    [self presentViewController:picker animated:NO completion:nil];
}
#pragma mark --runtime test
- (void)runTimeTest{
    
     [self.navigationController pushViewController:[STRuntimeStudyViewController new] animated:YES];
}
#pragma mark --struct test
- (void)structTest{
    
    [self.navigationController pushViewController:[STStructViewController new] animated:YES];
}
#pragma mark --kvo test
- (void)kvoTest{
    
    [self.navigationController pushViewController:[STKvoTestViewController new] animated:YES];
}
#pragma mark --blocktest
- (void)blockTest{
    
    [self.navigationController pushViewController:[STBlockTestViewController  new] animated:YES];
}
#pragma mark --UIViewController Test
- (void)imagePickerVCTest{
    
    [self presentViewController:[[STImagePickerController alloc] initWithDefultRootVCHandle:^(NSArray<STPhotoModel *> *array) {
        
    }] animated:YES completion:^{
        
    }];
    
    
}
- (void)TZIpickerVCTest{
    [self presentViewController:[[TZImagePickerController alloc] initWithMaxImagesCount:100 delegate:self] animated:YES completion:^{
        
    }];
}
- (void)webViewVCTest{
    
    STWebViewController * vc = [[STWebViewController alloc] initWithUrl:@"https://www.baidu.com"];
    vc.progressBackgroundColor = [UIColor redColor];
    vc.progressTintColor = [UIColor orangeColor];
    [self.navigationController pushViewController:vc animated:YES];
}
#pragma mark --View Test
- (void)maskViewTest{
    
}
- (void)maskLayerTest{
    
}
#pragma mark --NetWork Test
- (void)yuyinNetWorkTest{
    AFHTTPSessionManager *mgr = [AFHTTPSessionManager manager];
    [mgr.requestSerializer setTimeoutInterval:10];

    mgr.responseSerializer = [AFHTTPResponseSerializer serializer];
    NSString * url = @"https://api.suiyueyule.com/1.0.2/feed/new?lang=utf8&page=1";
    NSDictionary * dic = @{
                           @"datatype":@"jsonp",
                           @"playlist_id":@"5483",
                           @"uid":@"0",
                           @"sign":@"3041a7dc9a67201534bd3773beef7f814360742303da5b2605793b771f733731×trap=1496980564311",
                           @"api_key":@"08b1e567157582019f7fe639c841c42a",
                           @"callback":@"data",
                           @"_":@"1498795261"
                         };
    url = @"http://wawa.fm:9090/wawa/api.php/statics/statPlayList?datatype=jsonp&playlist_id=5483&uid=0&sign=8840f256ee6f405a6e3ed8ef77af4d47f7f15dfba4a40492c46105d18269c482×trap=1496994558060&api_key=08b1e567157582019f7fe639c841c42a&callback=data&_=1496994557444";
    
    url = @"http://wawa.fm:9090/wawa/api.php/statics/statPlayList";
    [mgr GET:url  parameters:dic progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        
        NSString * str = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];

        str = [str substringToIndex:str.length - 1];
        str = [str substringFromIndex:7];
        
        
        
        NSLog(@"%@",dic);
        
        
        
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        
        
    }];
    
    
}
- (void)yuyinListTest{
    

    
    AFHTTPSessionManager *mgr = [AFHTTPSessionManager manager];
    [mgr.requestSerializer setTimeoutInterval:10];
   
   // mgr.responseSerializer = [AFHTTPResponseSerializer serializer];
    NSString * url = @"http://www.mochen988.com/lottery/api/u/v1/lottery/trend?lottery=RDLFC&issuecount=720&_=1489204861";
//    url = @"https://www.swedishlottery.se/lotto/resulat/lottery/number?lottery=KN-X&issueNo=25-07-2017-1149&_=1500980080774";
    url = @"https://www.swedishlottery.se/lotto/resulat/lottery/number?lottery=KN-X&issueNo=24-07-2017-1701&_=1500980080774";
    //3月27 有 昨日的17：01 是第一期 北京18：00 瑞典11：00
    mgr.requestSerializer = [AFJSONRequestSerializer serializer];
    [mgr.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    [mgr.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];
    [mgr.requestSerializer setValue:@"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:54.0) Gecko/20100101 Firefox/54.0" forHTTPHeaderField:@"User-Agent"];
    [mgr.requestSerializer setValue:@"zh-Hans-CN;q=1" forHTTPHeaderField:@"Accept-Language"];
    [mgr.requestSerializer setValue:@"gzip, deflate" forHTTPHeaderField:@"Accept-Encoding"];
    
    [mgr.requestSerializer setValue:@"XMLHttpRequest" forHTTPHeaderField:@"X-Requested-With"];
//    [mgr.requestSerializer setValue:@"http://www.mochen988.com/lottery/chart.html?lt=RDLFC" forHTTPHeaderField:@"Referer"];
//    [mgr.requestSerializer setValue:@"JSESSIONID=DC0DDE1AE84E38083BDEDD49B77A07B6; visid_incap_664792=4CMxuxMVQIWUZSFo4Gz3A6eBcFkAAAAAQUIPAAAAAABxl6x1I5nQacCAnf4HkLUv; incap_ses_401_664792=lZqNEcllryGGpC+ThaSQBRQOd1kAAAAAJ/fAShQZX0w5NMqXCuIBpw==; IMGCODE=ImageCode-33242-e00a6721-23d9-4363-8537-ac4e53422df9-gE03kK; SIG=0cBPXeZij3GiFYUIemYXjk5QtUChfCl7hisEv9FJtm2iWwB7rbnHG9zoIRPEaQZY; ltData={%22CQSSC%22:%22qsm_zx_fs%22%2C%22WBGFFC%22:%22qsm_zx_fs%22%2C%22RDFFC%22:%22qsm_zx_fs%22%2C%22RBSSM%22:%22qsm_zx_fs%22%2C%22WBGMMC%22:%22qsm_zx_fs%22%2C%22RDLFC%22:%22qsm_zx_fs%22%2C%22XGPK10%22:%22cq5_cq5_cq5%22%2C%22GD11Y%22:%22rxfs_rxfs_1z1%22}; lt=RDLFC" forHTTPHeaderField:@"Cookie"];
    

    [mgr GET:url  parameters:nil progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        
//        NSString * str = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
//        
//        str = [str substringToIndex:str.length - 1];
//        str = [str substringFromIndex:7];
        
      
        
        NSString  *str = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
        
        str = [str substringFromIndex:7];
        str = [str substringToIndex:str.length - 1];
        
        NSData * data = [str dataUsingEncoding:NSUTF8StringEncoding];
        
          id obj = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:nil];
        
      
        
        
        
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        
        
    }];

}
- (void)hgTest{
    
    AFHTTPSessionManager *mgr = [AFHTTPSessionManager manager];
    [mgr.requestSerializer setTimeoutInterval:10];
    
    
    NSString * url = @"http://www.lottokn.kr/";
    mgr.requestSerializer = [AFHTTPRequestSerializer serializer];
    mgr.responseSerializer = [AFHTTPResponseSerializer serializer];
    [mgr.requestSerializer setValue:@"PCID=15003647255110287172487; RC_RESOLUTION=1920*1080; RC_COLOR=24" forHTTPHeaderField:@"Cookie"];
    [mgr.requestSerializer setValue:@"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" forHTTPHeaderField:@"Accept"];
    [mgr.requestSerializer setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    mgr.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];
    [mgr.requestSerializer setValue:@"http://www.lottokn.kr/" forHTTPHeaderField:@"Referer"];
    [mgr.requestSerializer setValue:@"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:54.0) Gecko/20100101 Firefox/54.0" forHTTPHeaderField:@"User-Agent"];
    [mgr.requestSerializer setValue:@"zh-Hans-CN;q=1" forHTTPHeaderField:@"Accept-Language"];
    [mgr.requestSerializer setValue:@"gzip, deflate" forHTTPHeaderField:@"Accept-Encoding"];
     [mgr.requestSerializer setValue:@"1" forHTTPHeaderField:@"Upgrade-Insecure-Requests"];
   
    [mgr.requestSerializer setValue:@"XMLHttpRequest" forHTTPHeaderField:@"X-Requested-With"];
    
 
    NSDictionary * dic = @{@"nowPage":@"1",@"searchDate":@"2017722",@"calendar":@"2017-7-22"};
    
    [mgr POST:url  parameters:dic progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        

        
        
        NSString  *str = [[NSString alloc] initWithData:responseObject encoding:NSASCIIStringEncoding];
        
        NSRange  range = [str rangeOfString:@"<tbody>"];
        
        str = [str substringFromIndex:range.location+range.length];
        NSRange  range1 = [str rangeOfString:@"</tbody>"];
        str = [str substringToIndex:range1.location];
        
        NSArray * array = [str componentsSeparatedByString:@"</tr>"];
        NSArray * tenArray = [array subarrayWithRange:NSMakeRange(0, 10)];
        
        NSMutableArray * dicArray = [NSMutableArray new];
        
        for (NSString * obj in tenArray) {
            
            NSArray * firtsArray = [obj componentsSeparatedByString:@"</td>"];
            NSString * one = [firtsArray[0] stringByReplacingOccurrencesOfString:@"<tr>" withString:@""];
            one = [one stringByReplacingOccurrencesOfString:@"<td>" withString:@""];
            one = [one stringByReplacingOccurrencesOfString:@"\r" withString:@""];
            one = [one stringByReplacingOccurrencesOfString:@"\n" withString:@""];
            one = [one stringByReplacingOccurrencesOfString:@"\t" withString:@""];
            
            NSString * two = [firtsArray[1] stringByReplacingOccurrencesOfString:@"<tr>" withString:@""];
            two = [two stringByReplacingOccurrencesOfString:@"<td>" withString:@""];
            two = [two stringByReplacingOccurrencesOfString:@" " withString:@""];
            two = [two stringByReplacingOccurrencesOfString:@"-" withString:@""];
            
            NSString * three = [firtsArray[2] stringByReplacingOccurrencesOfString:@"<tr>" withString:@""];
            three = [three stringByReplacingOccurrencesOfString:@"<td>" withString:@""];
            three = [three stringByReplacingOccurrencesOfString:@" " withString:@""];
            
            [dicArray addObject:@{@"time":one,@"expect":two,@"originOpenCode":three}];
        }
        
        
        
        id obj = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingAllowFragments error:nil];
        
        NSLog(@"%@",obj);
        
        
        
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        
        
    }];
}

- (void)zhongcaiqiangliqiutTest{
    
    
    
    AFHTTPSessionManager *mgr = [AFHTTPSessionManager manager];
    [mgr.requestSerializer setTimeoutInterval:10];
    

    NSString * url = @"http://zc393.com:8088/proxy_v2";
    mgr.requestSerializer = [AFJSONRequestSerializer serializer];
    [mgr.requestSerializer setValue:@"to_view=; convert_1=78; convert_49=78; convert_20051=78; zcyl_=\"2|1:0|10:1501214732|5:zcyl_|624:eyJyZWdfdGltZSI6ICIyMDE3MDcyNzE5NTkwMiIsICJyZWdfaXAiOiAiMC4wLjAuMCIsICJzaG93X3BhcmVudF9xcSI6IDAsICJuaWNrX25hbWUiOiAiIiwgIm1vbmV5IjogIjAuMDAwIiwgInVzZXJfdHlwZSI6ICIwIiwgImhhc19wcm94eV9ib251cyI6IGZhbHNlLCAicHJldl9sb2dpbl90aW1lIjogIjIwMTcwNzI3MjAwMjEzIiwgInVzZXJfY29kZSI6ICI1MjY4MyIsICJlcnJvcl9jb2RlIjogMCwgImxvZ2luX2lwIjogIjE4Mi4xNTAuMjQuMTAiLCAibW9uZXlfdHlwZSI6ICIxIiwgInRpZXIiOiAiNCIsICJ1c2VyX2lkIjogIjI5ODkzIiwgInByZXZfbG9naW5faXAiOiAiMTgyLjE1MC4yNC4xMCIsICJsb2dpbl90aW1lIjogIjIwMTcwNzI4MTEzNTUxIiwgInVzZXJfbmFtZSI6ICJzeGwxNjg4IiwgImhhc19wcm94eV93YWdlIjogZmFsc2UsICJ1X251bSI6ICJCak9rTHBxNGRiaVZFd3I4WnMydVdkQzJLU2hvQXlDTSJ9|a7b00d1017617e08b0167120aa844af6fe977e747001d944463661aa9b154c99\"; convert_20011=78" forHTTPHeaderField:@"Cookie"];
    
    [mgr.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    
    [mgr.requestSerializer setValue:@"http://zc393.com:8088/zcyl/static/html/lottery/chart.html?17020701&cp_id=20051" forHTTPHeaderField:@"Referer"];
    [mgr.requestSerializer setValue:@"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:54.0) Gecko/20100101 Firefox/54.0" forHTTPHeaderField:@"User-Agent"];
    [mgr.requestSerializer setValue:@"zh-Hans-CN;q=1" forHTTPHeaderField:@"Accept-Language"];
    [mgr.requestSerializer setValue:@"gzip, deflate" forHTTPHeaderField:@"Accept-Encoding"];
    [mgr.requestSerializer setValue:@"XMLHttpRequest" forHTTPHeaderField:@"X-Requested-With"];

    
    NSDictionary * dic = @{@"command":@"lottery_request_transmit",@"":@"{\"command_id\":23,\"lottery_id\":\"20051\",\"issue_status\":\"1\",\"count\":\"300\"}"};
    
    [mgr POST:url  parameters:dic progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        
        //        NSString * str = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
        //
        //        str = [str substringToIndex:str.length - 1];
        //        str = [str substringFromIndex:7];
        
        
        
        NSString  *str = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
        
        str = [str substringFromIndex:7];
        str = [str substringToIndex:str.length - 1];
        
        NSData * data = [str dataUsingEncoding:NSUTF8StringEncoding];
        
        id obj = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:nil];
        
        
        
        
        
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        
        
    }];
    
}
- (void)nomarlNetWorkTest{
    AFHTTPSessionManager *mgr = [AFHTTPSessionManager manager];
    [mgr.requestSerializer setTimeoutInterval:10];
    NSDictionary * dic = @{
                           @"id":@"45812",
                           @"type":@"0"};
    
    mgr.requestSerializer = [AFJSONRequestSerializer serializer];
    [mgr.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    [mgr.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];
    [mgr.requestSerializer setValue:@"Fiil/1.7.2/(iPhone;10.2;Sacle/3.00)" forHTTPHeaderField:@"User-Agent"];
    [mgr.requestSerializer setValue:@"zh-Hans-CN;q=1" forHTTPHeaderField:@"Accept-Language"];
    [mgr.requestSerializer setValue:@"gzip, deflate" forHTTPHeaderField:@"Accept-Encoding"];
    
    [mgr.requestSerializer setValue:@"XMLHttpRequest" forHTTPHeaderField:@"X-Requested-With"];
    [mgr.requestSerializer setValue:@"03D11B58-9B26-4E34-9368-292FFF0E0EB6" forHTTPHeaderField:@"X-UUID"];
    [mgr.requestSerializer setValue:@"0" forHTTPHeaderField:@"X-Channel"];
    [mgr.requestSerializer setValue:@"com.suiyueyuele.suiyue.ios" forHTTPHeaderField:@"X-BundleId"];
    
    [mgr GET:@"https://api.suiyueyule.com/1.0.2/feed/new?lang=utf8&page=1" parameters:nil progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        
    }];
    
    
}
- (void)downdTest{
    NSLog(@"%@",NSTemporaryDirectory());
    AFHTTPSessionManager *mgr = [AFHTTPSessionManager manager];
    [mgr.requestSerializer setTimeoutInterval:10];
    //https://al-qn-echo-cp-cdn.app-echo.com/c2_96k/ee3a5c6709880b71ff2b4ee4e4e2fe745ec5dca127d16d35ec05197063ccb848259bf40a.mp3?1486955512
    NSURLSessionDownloadTask *download = [mgr downloadTaskWithRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"https://video-cdn.suiyueyule.com/o_1bdc2n9291tmcs4e1oj11k448gc.ts.mp4?auth_key=1492074663-0-0-d066552424ec3a9c2d720c86a9cea7bb"]] progress:^(NSProgress * _Nonnull downloadProgress) {
        
    } destination:^NSURL * _Nonnull(NSURL * _Nonnull targetPath, NSURLResponse * _Nonnull response) {
        NSFileManager *fileManager = [[NSFileManager alloc] init];
        NSString *pathDocuments = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex:0];
        NSString *createDir = [NSString stringWithFormat:@"%@/echo_music", pathDocuments];
        
        // 判断文件夹是否存在，如果不存在，则创建
        if (![[NSFileManager defaultManager] fileExistsAtPath:createDir]) {
            [fileManager createDirectoryAtPath:createDir withIntermediateDirectories:YES attributes:nil error:nil];
        } else {
            NSLog(@"FileDir is exists.");
        }
        NSString *cachesPath = createDir;
        NSString *path = [cachesPath stringByAppendingPathComponent:response.suggestedFilename];
        NSLog(@"%@",path);
        return [NSURL fileURLWithPath:path];
    } completionHandler:^(NSURLResponse * _Nonnull response, NSURL * _Nullable filePath, NSError * _Nullable error) {
        
    }];
    [download resume];
}
@end
